package com.ali.gts.controller;

import com.ali.gts.domain.Person;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class TestController {


    private final Logger logger = LoggerFactory.getLogger(TestController.class);

    @Autowired
    Person person;

    @Autowired
    ApplicationContext applicationContext;

    /**
     *
     * http://localhost:8080/user
     *  Shift+Shift搜索任何东西
     *
     */
    @RequestMapping("/user")
    public String get(){
        logger.info("gaohq===");

        return "user";
    }

    /**
     *
     * bean 之间的依赖，就是测试bean的创建顺序
     *
     * @return
     */
    //@ResponseBody
    @RequestMapping("/test")
    public String testDependency(){

        System.out.println("test bean 之间的依赖关系,先创建car 在创建peson");
        person.setAge(11);

        return "user";
    }

    @RequestMapping("/testFactory")
    public Integer testFactory(){
        System.out.println("test bean 之间的依赖关系,先创建car 在创建peson");
        person.setAge(11);
        return 200;
    }



}
